package net.cooltain.warhammer.running.window.panel;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JLabel;

import net.cooltain.warhammer.framework.constant.ConstantPicture;
import net.cooltain.warhammer.running.entity.DeskZone;
import net.cooltain.warhammer.running.entity.MotionPlayerZone;
import net.cooltain.warhammer.running.window.MainFrame;

public class DeskCardLabel extends JLabel implements MouseListener {
	
	private MotionPlayerZone player ; // 显示这个卡片的玩家,不一定是拥有卡片的人
	private DeskZone   deskZone ;     // 卡牌堆
	
	public DeskCardLabel(MotionPlayerZone player,DeskZone deskZone) {
		super();
		this.setDoubleBuffered(true);
		this.deskZone = deskZone;
		this.player = player;
	}

	
	public void paintComponent(Graphics g){ 
		super.paintComponent(g);
		g.setColor(Color.LIGHT_GRAY);
		g.drawString("抽牌堆 ("+deskZone.getCardSize()+")", 8, 15);
		BufferedImage backImage = null;
		try {
			backImage = ImageIO.read(new File(ConstantPicture.PIC_CARD_BACK));
		} catch (IOException e) {
			e.printStackTrace();
		}
		int currentX = (this.getWidth()-MainFrame.CARD_W)/2 -4;
		int currentY = (this.getHeight()-MainFrame.CARD_H)/2 +10;
		for(int i=0; i<deskZone.getCardSize() && i<10; i++){
			g.drawImage(backImage,currentX, currentY, MainFrame.CARD_W, MainFrame.CARD_H, null);
			currentX ++;
			currentY --;
		}
	}
	
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
	}
	
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

}
